package com.todo.user.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhangwenxiang
 * @date 2024/4/8 10:52
 * @description
 */
@Getter
@AllArgsConstructor
public enum UserOperateTypeEnum {

    REGISTER(1, "REGISTER", "注册"),
    UPDATE(2, "UPDATE", "更新个人信息"),
    LOG_OFF(3, "LOG_OFF", "注销"),
    TRANSFER_PHONE(4, "TRANSFER_PHONE", "手机号换绑"),
    LOGIN(5, "LOGIN", "登录"),
    TRANSFER_PASSWORD(6, "TRANSFER_PASSWORD", "更换密码"),
    ADMIN_OPERATE(7, "ADMIN_OPERATE", "运营操作"),
    ;

    private static Map<Integer, UserOperateTypeEnum> typeMap = Arrays
            .stream(UserOperateTypeEnum.values())
            .collect(Collectors.toMap(UserOperateTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static UserOperateTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
